<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>选项式vs组合式</title>
  </head>
  <body>
    <div id="app">
      <p>{{ count }}</p>
      <button v-on:click="add">btn</button>
    </div>

    <script src="./lib/vue3.js"></script>

    <script>
      const { createApp, ref } = Vue;

      // 选项式api的写法(同时也是vue2的写法)
      // createApp({
      //   data: function() {
      //     return {
      //       count: 1,
      //     };
      //   },
      //   methods: {
      //     add() {
      //       this.count++;
      //     },
      //   },
      // }).mount("#app");

      // 组合式api(vue3新增的一种语法)
      createApp({
        setup() {
          const count = ref(1);
          const add = () => {
            count.value++;
          };

          return { count, add };
        },
      }).mount("#app");
    </script>
  </body>
</html>
